Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations for instances with a lot of hostgroups #3349

Merged
merged 3 commits into from
Mar 20, 2021
Merged

Conversation

renecannao
Copy link
Contributor

This PR speeds up performance in MySQL_HostGroups_Manager if there are a lot of servers/hostgroups.
Specifically:

  • MySQL_HostGroups_Manager::read_only_action() can scale hundreds or thousands of times. This avoid unnecessary connection pool locks
  • MySQL_HostGroups_Manager::HGC_lookup() uses an unordered_map in case there are more than 100 hostgroups

This commit rewrites MySQL_HostGroups_Manager::read_only_action() in way to
reduce the calls to SQLite. It relies on two new std::set() :
- read_only_set1: if the server is already in a writer hostgroup
- read_only_set2: a cache to track the first time that a server has RO=0

Added also an index on MySQL_HostGroups_Manager,
ON mysql_servers (hostname,port)
HostGroups are stored in an array of pointers.
This commit allows the lookup using an unordered_map if the number of
Hostgroups is greater than 100.
For less number of hostgroups, a sequential scan seems more efficient.

This also introduce a test for micro benchmark.
@renecannao renecannao merged commit 26790c3 into v2.1.1 Mar 20, 2021
@renecannao renecannao deleted the v2.1.1-MonRo branch June 4, 2021 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant